package cn.stylefeng.guns.modular.web.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.modular.web.entity.SmPlanLog;
import cn.stylefeng.guns.modular.web.mapper.SmPlanLogMapper;
import cn.stylefeng.guns.modular.web.service.ISmPlanLogService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * 描述：存钱打卡记录表 service业务层
 * 作者：chenhuiyan
 * 时间：2020-04-18
 */
@Service
@Transactional(readOnly = true)
public class SmPlanLogServiceImpl extends ServiceImpl<SmPlanLogMapper, SmPlanLog> implements ISmPlanLogService {

    /**
     * 查询列表
     * @param params
     * @return
     */
    public Page<Map<String, Object>> list(Map<String, Object> params) {

        //日期范围处理
        params.put("today", "");
        params.put("startTime", "");
        params.put("endTime", "");
        if(ToolUtil.isNotEmpty(params.get("clockDate"))){
            String createDate = params.get("clockDate") + "";
            String[] createDateArr = createDate.split(" - ");
            if(createDateArr[0].equals(createDateArr[1])){
                params.put("today", createDateArr[0]);
            }else{
                params.put("startTime", createDateArr[0]);
                params.put("endTime", createDateArr[1]);
            }
        }

        Page page = LayuiPageFactory.defaultPage();
        return this.baseMapper.list(page, params);
    }

}
